<?php
/**
 * @user:andy
 * @date:2021/7/4
 * @company:http://www.sjdphp.com
 * @desc:
 */

namespace app\admin\controller;


use app\common\controller\BackBaseController;
use app\common\server\Json;

class SystemLog extends BackBaseController
{
    protected $model_id = 'system_log_id';
    protected $model_status = 'log_status';
    protected $model_desc = 'system_log_id desc';


    public function status()
    {
        if($this->request->isPost()){
            ## 接受参数并校验
            $id = $this->request->param($this->model_id,'intval');
            if(empty($id)) return Json::error("参数错误");

            ## 查询数据
            $class = self::getBusExample($this->request->controller());
            $info = $class::getInfo(array($this->model_id => $id));

            if($info[$this->model_status] == config("project.mysql_code.table_normal")){
                return Json::success("无法修改已处理的状态");
            }else{
                ## 要修改的信息
                $param = array(
                    $this->model_id => $id,
                    $this->model_status => $info[$this->model_status] == config("project.mysql_code.table_pending") ? config("project.mysql_code.table_normal") : config("project.mysql_code.table_normal"),
                );
            }
            return $class::insertOrUpdateAndDel($param,2);
        }else{
            return Json::error("请求方式错误");
        }
    }

}